package com.yiwei.hdb.view;

import android.content.Context;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.os.Handler;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.method.ScrollingMovementMethod;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.allen.library.SuperButton;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.BitmapImageViewTarget;
import com.bumptech.glide.request.target.ImageViewTarget;
import com.bumptech.glide.request.target.Target;
import com.yiwei.hdb.R;
import com.yiwei.hdb.activity.EmailIdentityActivity;
import com.yiwei.hdb.activity.LevelRuleActivity;
import com.yiwei.hdb.adapter.PhonePwdAdapterNew;
import com.yiwei.hdb.model.DealTypesModel;
import com.yiwei.hdb.model.PhonePwdModel;
import com.yiwei.hdb.util.DisplayUtil;
import com.yiwei.hdb.util.PreferenceUtils;
import com.yiwei.hdb.util.ToastUtil;
import com.yiwei.hdb.util.UI;
import com.yiwei.hdb.util.Util;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;
import uk.co.senab.photoview.PhotoView;
import uk.co.senab.photoview.PhotoViewAttacher;

/**
 * 自定义对话框
 * Created by Master.Dong on 2016/4/13.
 */
public class Dialog {


    /**
     * 分享对话框
     *
     * @param context
     * @param money
     * @param payType
     * @param name
     * @param dialogClickListener
     * @return
     */
    public static android.app.Dialog showPayDialog(Context context,
                                                   final String money, String payType, String name,
                                                   final DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        dialog.setCancelable(true);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_pay,
                null);
        dialog.setContentView(view);
        ((TextView) view.findViewById(R.id.money)).setText(money);
        ((TextView) view.findViewById(R.id.card)).setText(payType);
        ((TextView) view.findViewById(R.id.name)).setText(name);

        view.findViewById(R.id.pay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View arg0) {
                dialog.dismiss();
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        dialogClickListener.confirm();
                    }
                }, 200);
            }
        });
        ((LinearLayout) view.findViewById(R.id.ll_close)).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        lp.width = Util.getDisplayMetrics(context).widthPixels;
        mWindow.setGravity(Gravity.BOTTOM);
        // 添加动画
        mWindow.setWindowAnimations(R.style.dialogAnim);
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    /**
     * 显示无标题的默认按钮
     *
     * @param context             上下文
     * @param content             内容
     * @param leftButton          左边按钮
     * @param rightButton         右边按钮
     * @param dialogClickListener 点击事件回调
     * @return
     */
    public static android.app.Dialog showDefaultDialog(Context context, String title, String content,
                                                       String leftButton, String rightButton, boolean showCloseBtn,
                                                       final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_dialog, null);
        dialog.setContentView(view);
        LinearLayout titleView = (LinearLayout) view.findViewById(R.id.title_view);
        TextView mTitle = (TextView) view.findViewById(R.id.title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        TextView mLeftBtn = (TextView) view.findViewById(R.id.left_button);
        TextView mClose = (TextView) view.findViewById(R.id.close);
        if (showCloseBtn) mClose.setVisibility(View.VISIBLE);
        else mClose.setVisibility(View.INVISIBLE);

        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            titleView.setVisibility(View.VISIBLE);
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.line)).setVisibility(View.VISIBLE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });
        mClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showV3DefaultDialog(Context context, String title, String content,
                                                         String leftButton, String rightButton,
                                                         final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_tips_confirm_v3, null);
        dialog.setContentView(view);

        TextView mTitle = (TextView) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.txt_content);
        TextView mLeftBtn = (TextView) view.findViewById(R.id.left_button);

        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.line)).setVisibility(View.VISIBLE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showV3DefaultDialog(Context context, String title, Spanned content,
                                                         String leftButton, String rightButton,
                                                         final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_tips_confirm_v3, null);
        dialog.setContentView(view);

        TextView mTitle = (TextView) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.txt_content);
        TextView mLeftBtn = (TextView) view.findViewById(R.id.left_button);

        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.line)).setVisibility(View.VISIBLE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showDefaultRedBlackDialog(Context context, String title, String content,
                                                               String leftButton, String rightButton, boolean showCloseBtn,
                                                               final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_dialog_red_black, null);
        dialog.setContentView(view);
        LinearLayout titleView = (LinearLayout) view.findViewById(R.id.title_view);
        TextView mTitle = (TextView) view.findViewById(R.id.title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        TextView mLeftBtn = (TextView) view.findViewById(R.id.left_button);
        TextView mClose = (TextView) view.findViewById(R.id.close);
        if (showCloseBtn) mClose.setVisibility(View.VISIBLE);
        else mClose.setVisibility(View.INVISIBLE);

        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            titleView.setVisibility(View.VISIBLE);
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.line)).setVisibility(View.VISIBLE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });
        mClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showSystemDefaultDialog(Context context, String title, String content,
                                                             String leftButton, String rightButton, boolean showCloseBtn,
                                                             final DialogSystemDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_dialog, null);
        dialog.setContentView(view);
        dialog.getWindow().setType((WindowManager.LayoutParams.TYPE_SYSTEM_ALERT));
        LinearLayout titleView = (LinearLayout) view.findViewById(R.id.title_view);
        TextView mTitle = (TextView) view.findViewById(R.id.title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        TextView mLeftBtn = (TextView) view.findViewById(R.id.left_button);
        TextView mClose = (TextView) view.findViewById(R.id.close);
        if (showCloseBtn) mClose.setVisibility(View.VISIBLE);
        else mClose.setVisibility(View.INVISIBLE);

        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            titleView.setVisibility(View.VISIBLE);
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.line)).setVisibility(View.VISIBLE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });
        mClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                dialogClickListener.close();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    /**
     * 显示借款需知对话框
     *
     * @param context 上下文
     * @param
     * @return
     */
    public static android.app.Dialog showLoanDialoLg(Context context, List<DealTypesModel.DataBean> data) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.loan_dialog, null);
        dialog.setContentView(view);
        ((TextView) view.findViewById(R.id.load_percent)).setText("居间服务费为借款本金" + data.get(0).protocol.account_manage_fee + "%，若逾期，需每日收取借款本金" + data.get(0).protocol.manage_impose_fee + "%作为违约金");
//        ((TextView) view.findViewById(R.id.txt_yuqi)).setText("规定还款日未还款，需缴纳逾期违约金" + "元每天");
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i).repaytime == 7) {
                switch (data.get(i).maximum) {
                    case 500:
                        ((TextView) view.findViewById(R.id.txt_fir2_one)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 600:
                        ((TextView) view.findViewById(R.id.txt_fir2_two)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 700:
                        ((TextView) view.findViewById(R.id.txt_fir2_three)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 800:
                        ((TextView) view.findViewById(R.id.txt_fir2_four)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 900:
                        ((TextView) view.findViewById(R.id.txt_fir2_five)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 1000:
                        ((TextView) view.findViewById(R.id.txt_fir2_six)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                }
            } else if (data.get(i).repaytime == 14) {
                switch (data.get(i).maximum) {
                    case 500:
                        ((TextView) view.findViewById(R.id.txt_sec2_one)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 600:
                        ((TextView) view.findViewById(R.id.txt_sec2_two)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 700:
                        ((TextView) view.findViewById(R.id.txt_sec2_three)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 800:
                        ((TextView) view.findViewById(R.id.txt_sec2_four)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 900:
                        ((TextView) view.findViewById(R.id.txt_sec2_five)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                    case 1000:
                        ((TextView) view.findViewById(R.id.txt_sec2_six)).setText(data.get(i).services_detail.fast_audit_fee);
                        break;
                }
            }
        }
        dialog.setCancelable(false);
        ((ImageView) view.findViewById(R.id.close)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                    }
                });
        ((TextView) view.findViewById(R.id.btn_cancel)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                    }
                });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    /**
     * 显示借款需知对话框
     *
     * @param context 上下文
     * @return
     */
//    public static android.app.Dialog showLevelUpDialog(Context context) {
//        final android.app.Dialog dialog = new android.app.Dialog(context,
//                R.style.DialogStyle);
//        View view = LayoutInflater.from(context)
//                .inflate(R.layout.dialog_level_up, null);
//        dialog.setContentView(view);
//        view.findViewById(R.id.btn_ok).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                dialog.dismiss();
//            }
//        });
//        view.findViewById(R.id.btn_rule).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Util.startActivity(context, LevelRuleActivity.class);
//                dialog.dismiss();
//            }
//        });
//        Window mWindow = dialog.getWindow();
//        WindowManager.LayoutParams lp = mWindow.getAttributes();
//        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
//            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
//        } else {
//            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
//        }
//        mWindow.setAttributes(lp);
//        dialog.show();
//        return dialog;
//    }


    /**
     * 显示借款需知对话框
     *
     * @param context 上下文
     * @return
     */
    public static android.app.Dialog showFriendlyTipDialog(Context context) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_friendly_tip, null);
        dialog.setContentView(view);
        view.findViewById(R.id.ok).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //显示注册成功提示
    public static android.app.Dialog showRegisterTipDialog(Context context) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_register_tip, null);
        dialog.setContentView(view);
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
//        Glide.with(context).load(R.mipmap.img_register_tips).
//                bitmapTransform(new RoundedCornersTransformation(context, DisplayUtil.dip2px(context, 5), 0, RoundedCornersTransformation.CornerType.TOP)).
//                crossFade(1000).
//                into((ImageView) view.findViewById(R.id.imageView));
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //显示大头像
    public static android.app.Dialog showBigIcon(Context context) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_show_icon, null);
        PhotoView photoView = (PhotoView) view.findViewById(R.id.photo);
        Glide.with(context).load(PreferenceUtils.getString(context, "header", "")).error(R.mipmap.img_default_icon1).into(photoView);
        dialog.setContentView(view);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //显示大头像
    public static android.app.Dialog showBigIcon(Context context, int res) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_show_icon_progress, null);
        PhotoView photoView = (PhotoView) view.findViewById(R.id.photo);
        CircularProgress progressBar = (CircularProgress) view.findViewById(R.id.progressBar);

        Glide.with(context).load(res).listener(new RequestListener<Integer, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, Integer model, Target<GlideDrawable> target, boolean isFirstResource) {
                photoView.setImageResource(R.mipmap.img_default_icon1);
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, Integer model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                photoView.setImageDrawable(resource);
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
        dialog.setContentView(view);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //显示大头像
    public static android.app.Dialog showBigQrcodeIcon(Context context, byte[] res) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_show_icon_progress, null);
        PhotoView photoView = (PhotoView) view.findViewById(R.id.photo);
        CircularProgress progressBar = (CircularProgress) view.findViewById(R.id.progressBar);

        Glide.with(context).load(res).listener(new RequestListener<byte[], GlideDrawable>() {
            @Override
            public boolean onException(Exception e, byte[] model, Target<GlideDrawable> target, boolean isFirstResource) {
//                photoView.setImageResource(R.mipmap.img_default_icon1);
                ToastUtil.makeText(context, "加载失败");
                progressBar.setVisibility(View.GONE);
                dialog.dismiss();
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, byte[] model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                photoView.setImageDrawable(resource);
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
        dialog.setContentView(view);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    //显示大头像
    public static android.app.Dialog showBigIcon(Context context, String url) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_show_icon_progress, null);
        PhotoView photoView = (PhotoView) view.findViewById(R.id.photo);
        CircularProgress progressBar = (CircularProgress) view.findViewById(R.id.progressBar);
        Glide.with(context).load(url).error(R.mipmap.img_default_icon1).listener(new RequestListener<String, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                photoView.setImageDrawable(resource);
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
        dialog.setContentView(view);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showRecordImage(Context context, String url) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_show_icon_progress, null);
        PhotoView photoView = (PhotoView) view.findViewById(R.id.photo);
        CircularProgress progressBar = (CircularProgress) view.findViewById(R.id.progressBar);
        Glide.with(context).load(url).error(R.mipmap.message_icon).listener(new RequestListener<String, GlideDrawable>() {
            @Override
            public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
                progressBar.setVisibility(View.GONE);
                return false;
            }

            @Override
            public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
                photoView.setImageDrawable(resource);
                progressBar.setVisibility(View.GONE);
                return false;
            }
        }).into(photoView);
        dialog.setContentView(view);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
            @Override
            public void onPhotoTap(View view, float x, float y) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    /**
     * 显示查看支付流程对话框
     *
     * @param context 上下文
     * @return
     */
    public static android.app.Dialog showPayProcessTipDialog(final Context context, final DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_pay_tip, null);
        dialog.setContentView(view);
        view.findViewById(R.id.look_Payment_process).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                dialog.dismiss();
            }
        });
        ImageView imageView = (ImageView) view.findViewById(R.id.imageView);

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 11 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog needOtherData(Context context, final DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_v3_need_data, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showSubmitSuccessV3(Context context, final DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_v3_submit_success, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        return dialog;
    }

    /**
     * 显示手机服务密码对话框
     *
     * @param context 上下文
     * @return
     */
    public static android.app.Dialog showPhonePwdDialoLg(Context context, PhonePwdModel model) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.phone_pwd_dialog, null);
        dialog.setContentView(view);

        ListView listView = (ListView) view.findViewById(R.id.listview);
        PhonePwdAdapterNew adapter = new PhonePwdAdapterNew(context, model.getData());
        listView.setAdapter(adapter);

        dialog.setCancelable(false);
        ((ImageView) view.findViewById(R.id.close)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                    }
                });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static boolean isMobileNO(String mobiles) {

        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0,5-9]))\\d{8}$");

        Matcher m = p.matcher(mobiles);

        return m.matches();

    }

    public static boolean isEmail(String email) {
        if (null == email || "".equals(email)) return false;
        //Pattern p = Pattern.compile("\\w+@(\\w+.)+[a-z]{2,3}"); //简单匹配
        Pattern p = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");//复杂匹配
        Matcher m = p.matcher(email);
        return m.matches();
    }


    public static android.app.Dialog showAddAlipayV3(Context context, AlipayClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_add_alipay, null);
        dialog.setContentView(view);

        dialog.setCancelable(false);

        EditText editUser = (EditText) view.findViewById(R.id.edit_user);


        ((TextView) view.findViewById(R.id.left_button)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                    }
                });
        ((TextView) view.findViewById(R.id.right_button)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        if (TextUtils.isEmpty(UI.toString(editUser))) {
                            ToastUtil.makeText(context, "支付宝账号不能为空");
                            return;
                        }
//                        if (isMobileNO(UI.toString(editUser)) || isEmail(UI.toString(editUser))) {
                        dialogClickListener.confirm(UI.toString(editUser), dialog);
//                            dialog.dismiss();
//                        } else {
//                            ToastUtil.makeText(context, "请输入正确的支付宝账号").show();
//                        }
                    }
                });
        ((ImageView) view.findViewById(R.id.btn_clear)).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        editUser.setText("");
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 9;
        }
        mWindow.setAttributes(lp);
//        dialog.show();
        return dialog;
    }

    /**
     * 身份证信息确认对话框
     *
     * @param context
     * @param name
     * @param gender
     * @param identiey
     * @param address
     * @param dialogClickListener
     * @return
     */
    public static android.app.Dialog showIdcardDialog(Context context, boolean isEdit, String name, String gender, String identiey, String address, String rightBtn
            , final IdCardClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.idcard_dialog, null);
        dialog.setContentView(view);
        final EditText mName = (EditText) view.findViewById(R.id.name);
        mName.setText(name);
        ((TextView) view.findViewById(R.id.right_button)).setText(rightBtn);
        ((TextView) view.findViewById(R.id.gender)).setText(gender);
        ((TextView) view.findViewById(R.id.identiey)).setText(identiey);
        final EditText mAddress = (EditText) view.findViewById(R.id.address1);
        mAddress.setText(address);
        if (!isEdit) {
            view.findViewById(R.id.name_line).setVisibility(View.INVISIBLE);
            view.findViewById(R.id.address_line).setVisibility(View.INVISIBLE);
            mName.setEnabled(false);
            mAddress.setEnabled(false);
        }
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm(mName.getText().toString().trim(), mAddress.getText().toString().trim());
                            }
                        }, 200);
                    }
                });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showInviteDialog(Context context, Spanned text) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_invite, null);
        ((TextView) view.findViewById(R.id.txt_tips)).setText(text);
        ((TextView) view.findViewById(R.id.txt_tips)).setMovementMethod(ScrollingMovementMethod.getInstance());


        dialog.setContentView(view);

        dialog.setCancelable(true);
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showConfirmDialog(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_repay_confirm, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_repay).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.cancel();
                dialog.dismiss();
            }
        });

        view.findViewById(R.id.btn_success).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showRepayTipsDialog(Context context, String tips, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_repay_tips, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        ((TextView) view.findViewById(R.id.txt_tips)).setText(tips);
        view.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        view.findViewById(R.id.btn_success).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();

        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog gotoRepayMoney(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_repay_money, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();

        mWindow.setAttributes(lp);
        return dialog;
    }


    public static android.app.Dialog gotoBankIdentity(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_bank_identity_show, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        TextView txtTips = (TextView) view.findViewById(R.id.txt_tips);
        UI.setTvHtml(txtTips, R.string.dialog_bank_identity_tips);
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();

        mWindow.setAttributes(lp);
        return dialog;
    }

    //    实名认证
    public static android.app.Dialog gotoShiMing(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_change_phone, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });


        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        lp.gravity = Gravity.CENTER;
        mWindow.setAttributes(lp);
        return dialog;
    }

    public static android.app.Dialog showPhoneDialog(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.change_phone_code_dialog, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        TextView txtContent = (TextView) view.findViewById(R.id.txt_content);
        txtContent.setText("请输入" + PreferenceUtils.getString(context, "mobile", "") + "收到的验证码");
        view.findViewById(R.id.left_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.right_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();

        mWindow.setAttributes(lp);
        return dialog;
    }

    public static android.app.Dialog gotoTongxunlu(Context context, DialogDefaultClickListener dialogDefaultClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_tongxunlu, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);
        view.findViewById(R.id.btn_cancel).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.cancel();
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.cancel();
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_open).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialogDefaultClickListener.confirm();
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();

        mWindow.setAttributes(lp);
        return dialog;
    }

    public static android.app.Dialog showIdcardImageDialog(Context context, String title,
                                                           final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_tips_image_idcard, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        ((TextView) view.findViewById(R.id.txt_title)).setText(title);
        view.findViewById(R.id.left_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                dialogClickListener.cancel();
            }
        });
        view.findViewById(R.id.right_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                dialogClickListener.confirm();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showFindUsername(Context context, String name,
                                                      final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_find_by_username, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        ((TextView) view.findViewById(R.id.txt_name)).setText(name);
        view.findViewById(R.id.btn_login).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                dialogClickListener.cancel();
            }
        });
        view.findViewById(R.id.btn_find_pass).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                dialogClickListener.confirm();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showResetFail(Context context) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_reset_pass_fail, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showCheckFail(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_check_fail_v3, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showSetGuestureSuccessDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_guesture_success, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showBankCardAddDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_bankcard_add, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });

        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showWithdrawSuccessDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_withdraw_success, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showPrizeDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_prize_show, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_close).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //还款失败弹窗
    public static android.app.Dialog showRepayFailDialog(Context context, DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_repay_fail, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.left_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.cancel();
                }
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.right_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        lp.gravity = Gravity.CENTER;
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //还款成功弹窗
    public static android.app.Dialog showRepaySuccessDialog(Context context, DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_repay_success, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.left_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.cancel();
                }
                dialog.dismiss();
            }
        });
        view.findViewById(R.id.right_button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        lp.gravity = Gravity.CENTER;
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //推广限制弹窗
    public static android.app.Dialog showExtensionLimitDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_extension_limit, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    //推广成功弹窗
    public static android.app.Dialog showExtensionSuccessDialog(Context context, DialogClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_extension_success, null);
        dialog.setContentView(view);
        dialog.setCancelable(false);

        view.findViewById(R.id.btn_submit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (dialogClickListener != null) {
                    dialogClickListener.confirm();
                }
                dialog.dismiss();
            }
        });
        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showDefaultV3Dialog(Context context, String title, String content,
                                                         String leftButton, String rightButton,
                                                         final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_v3_dialog, null);
        dialog.setContentView(view);

        SuperButton mTitle = (SuperButton) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        SuperButton mLeftBtn = (SuperButton) view.findViewById(R.id.left_button);


        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showDefaultV3Dialog(Context context, String title, Spanned content,
                                                         String leftButton, String rightButton,
                                                         final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_v3_dialog, null);
        dialog.setContentView(view);

        SuperButton mTitle = (SuperButton) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        SuperButton mLeftBtn = (SuperButton) view.findViewById(R.id.left_button);


        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public static android.app.Dialog showAlipayAddTips(Context context, String title, String content,
                                                       String leftButton, String rightButton,
                                                       final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.alipay_tips_dialog, null);
        dialog.setContentView(view);

        SuperButton mTitle = (SuperButton) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        SuperButton mLeftBtn = (SuperButton) view.findViewById(R.id.left_button);


        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((TextView) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showGuestrueDialog(Context context, String title, String content,
                                                        String leftButton, String rightButton,
                                                        final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.default_guesture_dialog, null);
        dialog.setContentView(view);

        SuperButton mTitle = (SuperButton) view.findViewById(R.id.txt_title);
        TextView mContext = (TextView) view.findViewById(R.id.content);
        SuperButton mLeftBtn = (SuperButton) view.findViewById(R.id.left_button);


        //标题
        if (TextUtils.isEmpty(title))
            mTitle.setVisibility(View.GONE);
        else {
            mTitle.setText(title);
        }
        //内容
        if (TextUtils.isEmpty(content)) {
            mContext.setVisibility(View.GONE);
        } else {
            mContext.setVisibility(View.VISIBLE);
            mContext.setText(content);
        }

        //左边按钮
        if (TextUtils.isEmpty(leftButton)) {
            mLeftBtn.setVisibility(View.GONE);
            ((View) view.findViewById(R.id.d_line)).setVisibility(View.GONE);
        } else {
            mLeftBtn.setVisibility(View.VISIBLE);
            mLeftBtn.setText(leftButton);
        }
        ((SuperButton) view.findViewById(R.id.right_button)).setText(rightButton);
        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }


    public static android.app.Dialog showIdcardConfirm(Context context, String name, String idcard,
                                                       final DialogDefaultClickListener dialogClickListener) {
        final android.app.Dialog dialog = new android.app.Dialog(context,
                R.style.DialogStyle);
        View view = LayoutInflater.from(context)
                .inflate(R.layout.dialog_idcard_confirm, null);
        dialog.setContentView(view);

        ((TextView)view.findViewById(R.id.txt_name)).setText(name);
        ((TextView)view.findViewById(R.id.txt_idcard)).setText(idcard);


        //标题
//        if (TextUtils.isEmpty(title))
//            mTitle.setVisibility(View.GONE);
//        else {
//            mTitle.setText(title);
//        }
//        //内容
//        if (TextUtils.isEmpty(content)) {
//            mContext.setVisibility(View.GONE);
//        } else {
//            mContext.setVisibility(View.VISIBLE);
//            mContext.setText(content);
//        }

        dialog.setCancelable(false);
        view.findViewById(R.id.left_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.cancel();
                            }
                        }, 200);
                    }
                });
        view.findViewById(R.id.right_button).setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View arg0) {
                        dialog.dismiss();
                        new Handler().postDelayed(new Runnable() {
                            @Override
                            public void run() {
                                dialogClickListener.confirm();
                            }
                        }, 200);
                    }
                });

        Window mWindow = dialog.getWindow();
        WindowManager.LayoutParams lp = mWindow.getAttributes();
        if (context.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {// 横屏
            lp.width = Util.getDisplayMetrics(context).heightPixels / 10 * 8;
        } else {
            lp.width = Util.getDisplayMetrics(context).widthPixels / 10 * 8;
        }
        mWindow.setAttributes(lp);
        dialog.show();
        return dialog;
    }

    public interface DialogClickListener {
        public abstract void confirm();

    }

    public interface DialogDefaultClickListener {
        public abstract void confirm();

        public abstract void cancel();
    }

    public interface AlipayClickListener {
        public abstract void confirm(String user, android.app.Dialog dialog);

        public abstract void cancel();
    }

    public interface DialogSystemDefaultClickListener {
        public abstract void confirm();

        public abstract void cancel();

        public abstract void close();
    }


    public interface IdCardClickListener {
        public abstract void confirm(String name, String address);

        public abstract void cancel();
    }


}
